import { get, post, del, put } from './axios'

export function createArticle (params) {
  return post('article', {
    isPrivate: params.isPrivate,
    title: params.title,
    description: params.description,
    categoryIds: params.categoryIds,
    content: params.content
  })
}

export function pagePublicArticle (params) {
  return post('article/public', {
    page: params.page,
    pageSize: params.pageSize,
    title: params.title,
    categoryIds: params.categoryIds
  })
}

export function startTopArticle (params) {
  return post('article/star_top', {
    title: params.title,
    categoryIds: params.categoryIds
  })
}

export function updateArticle (params) {
  return put('article', {
    isPrivate: params.isPrivate,
    title: params.title,
    description: params.description,
    categoryIds: params.categoryIds,
    content: params.content
  })
}

export function getArticle (id) {
  return get('article/' + id)
}

export function delArticle (id) {
  return del('article/' + id)
}

export function star (id) {
  return put('article/star', {
    articleId: id
  })
}

export function unStar (id) {
  return put('article/un_star', {
    articleId: id
  })
}

export function haveStar (id) {
  return get('article/star/' + id, {
    articleId: id
  })
}
